package com.demo.aop.simple;

import org.springframework.aop.framework.ProxyFactory;

/**
 * 描述：AOP Alliance接口实现
 *
 * @author lida
 * @time 2019/10/22 17:02
 */
public class Main {

	public static void main(String[] args) {
		//生成一个目标对象
		Agent target = new Agent();
		//生成一个代理的工厂
		ProxyFactory pf = new ProxyFactory();
		//配置相关的通知和织入的目标
		pf.addAdvice(new AgentDecorator());
		pf.setTarget(target);

		//从工厂获取代理后的对象
		Agent proxy = (Agent)pf.getProxy();

		target.speak();
		System.out.println("");
		proxy.speak();
	}
}
